<template>
  <div class="drop-cell">
    <div class='title'>
      {{index}}.{{title}}
    </div>
    <div class='content'>
      <Select :propArray="optionList" v-model="current"></Select>
    </div>
  </div>
</template>

<script>
import Select from './Select.vue';
import getOptionList from '../helpers/getOptionList'
import getNextMap from '../helpers/getNextMap'
export default {
  name: 'Dropdown',
  components: {
    Select
  },
  props: {
    index: Number,
    title: String,
    options: String,
    value: String
  },
  data() {
    return {
      current: '',
    }
  },
  computed: {
    optionList: function() {
      if (this.options && this.options.length > 0) {
        const {list} = getOptionList(this.options);
        return list
      }
      else {
        return []
      }
    },
    nextMap() {
      return getNextMap(this.options)
    }
  },
  watch: {
    current: function(val) {
      this.$emit('input', val, this.nextMap[val])
    }
  }
}
</script>

<style lang="scss">
.drop-cell {
  padding: 50px 40px 0;
}
.drop-cell > .title {
  font-size: 34px
}
.drop-cell > .content {
  margin-top: 20px;
  position: relative;
}

</style>